import {
  methods,
  request,
  request_address_local,
  testsource,
} from '../utils/request'; //设置自己的request路径

const actions = {
  getGradeSummary: {
    name: 'getGradeSummary',
    url: '/learninganalysis/gradeinfo/gradeSummary/get/', //后端接口
  },
  getGradeSummaryScoreDetial: {
    name: 'getGradeSummaryScoreDetial',
    url: '/learninganalysis/gradeinfo/detailscore/get/', //获取单个学生课程成绩列表
  },
  getStudentAnalysis: {
    name: 'getStudentAnalysis',
    url: '/learninganalysis/gradeinfo/learningAnalysis/get/', //获取单个学生课程成绩分析
  },
  getCetdetial: {
    //辅导员获取学生四六级成绩
    name: 'getCetdetial',
    url: '/learninganalysis/cet/getpart?instructorCode=',
  },
  getSecondClassDetail: {
    //辅导员获取学生二课成绩
    name: 'getSecondClassDetail',
    url: '/learninganalysis/extracurricular/getone?studentCode=',
  },
  getSchoolPrecaution: {
    //辅导员获取全部学生预警信息
    name: 'getSchoolPrecaution',
    url: '/learninganalysis/academicalert/getall?teacherCode=',
  },
  getPrecautionAnalysis: {
    //辅导员获取横向预警分析
    name: 'getPrecautionAnalysis',
    url: '/learninganalysis/academicalert/getclasscompare?teacherCode=',
  },
  getPrecautionDetail: {
    //辅导员获取预警学生的详细信息
    name: 'getPrecautionDetail',
    url: '/learninganalysis/academicalert/getone?studentCode=',
  },
  getOutclassSummary: {
    //辅导员获取所有学生的二课成绩
    name: 'getOutclassSummary',
    url: '/learninganalysis/extracurricular/getall',
  },
  getMentorMasterScoreList: {
    //育人团队带班成绩列表
    name: 'getMentorMasterScoreList',
    url: '/learninganalysis/gradeinfo/gradeForLeaderList/get/',
  },
  getMentorMasterOtherScore: {
    //育人团队获取其他成绩列表
    name: 'getMentorMasterOtherScore',
    url: '/learninganalysis/gradeinfo/otherGradeForLeader/get/',
  },
  getSecondClassDetailForStu: {
    //学生获取二课成绩详情
    name: 'getSecondClassDetailForStu',
    url: '/learninganalysis/extracurricular/getstudetail/',
  },
  getStudentClassTwoBystudentCode: {
    name: 'getStudentClassTwoBystudentCode',
    url: '/learninganalysis/extracurricular/getone',
  },
  getMentorOtherScore: {
    //班导师获得学生其他成绩
    name: 'getMentorOtherScore',
    url: '/learninganalysis/gradeinfo/otherGrade/get/',
  },
  getMentorScoreList: {
    //班导师获得学生一课成绩
    name: 'getMentorOtherScore',
    url: '/learninganalysis/gradeinfo/gradeList/get/',
  },
};
const customRequest = (action: any, token: any, formdata: any = null) => {
  let options: any = {
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      Accept: 'application/json',
      Authorization: token ? token : '',
    },
  };
  let url = action.url;
  switch (action.name) {
    case actions.getGradeSummary.name: //获取学生成绩汇总
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getGradeSummaryScoreDetial.name: //获取单个学生成绩列表
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getStudentAnalysis.name: //获取学生成绩分析
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getCetdetial.name: //辅导员获取学生四六级成绩
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getSecondClassDetail.name: //学生获取学生二课成绩
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getSchoolPrecaution.name: //辅导员获取全部学生预警信息
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getPrecautionAnalysis.name: //辅导员获取横向预警分析
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getPrecautionDetail.name: //辅导员获取预警学生的详细信息
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getOutclassSummary.name: //辅导员获取所有学生的二课成绩
      options['method'] = methods.get;
      break;
    case actions.getMentorMasterScoreList.name: ////育人团队带班成绩列表
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getMentorMasterOtherScore.name: //育人团队获取其他成绩列表
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getSecondClassDetailForStu.name: //学生获取二课详情
      options['method'] = methods.get;
      url = url + '?studentCode=' + formdata;
      break;
    case actions.getStudentClassTwoBystudentCode.name: //学生获取学生二课汇总
      options['method'] = methods.get;
      url += '?studentCode=' + formdata;
      break;
    case actions.getMentorOtherScore.name: //学生获取学生二课汇总
      options['method'] = methods.get;
      url += formdata;
      break;
    case actions.getMentorScoreList.name: //学生获取学生二课汇总
      options['method'] = methods.get;
      url += formdata;
      break;
    default:
  }
  return request(testsource + url, options);
};

export function getGradeSummary(token: string, formdata: any) {
  //获取学生成绩汇总
  return customRequest(actions.getGradeSummary, token, formdata);
}
export function getGradeSummaryScoreDetial(token: string, formdata: any) {
  //获取单个学生成绩列表
  return customRequest(actions.getGradeSummaryScoreDetial, token, formdata);
}
export function getStudentAnalysis(token: string, formdata: any) {
  //获取单个学生成绩分析
  return customRequest(actions.getStudentAnalysis, token, formdata);
}
export function getCetdetial(token: string, formdata: any) {
  //辅导员获取学生四六级成绩
  return customRequest(actions.getCetdetial, token, formdata);
}
export function getSecondClassDetail(token: string, formdata: any) {
  //学生获取学生二课成绩
  return customRequest(actions.getSecondClassDetail, token, formdata);
}
export function getSchoolPrecaution(token: string, formdata: any) {
  //辅导员获取全部学生预警信息
  return customRequest(actions.getSchoolPrecaution, token, formdata);
}
export function getPrecautionAnalysis(token: string, formdata: any) {
  //辅导员获取横向预警分析
  return customRequest(actions.getPrecautionAnalysis, token, formdata);
}
export function getPrecautionDetail(token: string, formdata: any) {
  //辅导员获取预警学生的详细信息
  return customRequest(actions.getPrecautionDetail, token, formdata);
}
export function getOutclassSummary(token: string, formdata: any) {
  //辅导员获取所有学生的二课成绩
  return customRequest(actions.getOutclassSummary, token, formdata);
}
export function getMentorMasterScoreList(token: string, formdata: any) {
  //育人团队带班成绩列表
  return customRequest(actions.getMentorMasterScoreList, token, formdata);
}
export function getMentorMasterOtherScore(token: string, formdata: any) {
  //育人团队获取其他成绩列表
  return customRequest(actions.getMentorMasterOtherScore, token, formdata);
}
export function getSecondClassDetailForStu(token: string, formdata: any) {
  //育人团队获取其他成绩列表
  return customRequest(actions.getSecondClassDetailForStu, token, formdata);
}
export function getStudentClassTwoBystudentCode(token: string, formdata: any) {
  //辅导员获取单个学生二课汇总
  return customRequest(
    actions.getStudentClassTwoBystudentCode,
    token,
    formdata,
  );
}
export function getMentorOtherScore(token: string, formdata: any) {
  //班导师获取其他成绩列表
  return customRequest(actions.getMentorOtherScore, token, formdata);
}
export function getMentorScoreList(token: string, formdata: any) {
  //班导师获取一课成绩列表
  return customRequest(actions.getMentorScoreList, token, formdata);
}
